/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.database.DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Valdigleis
 */
public class ConnectionDataBase {
    
    private static final String URL = "jdbc:derby:myDerby;create=true;user=derby;password=derby";
    
    private static final String DRIVER= "org.apache.derby.jdbc.EmbeddedDriver";
    
    public static Connection getConnection(){
        
        System.out.println("Conectado ao banco de dados");
        try{
            
            Class.forName(DRIVER);
            return DriverManager.getConnection(URL);
            
        }catch(ClassNotFoundException e){
            
            System.err.println("A 1ª exeção da fabrica");
            e.printStackTrace();
            
        }catch (SQLException e){
            
            System.err.println("A 2ª exeção da fabrica");
            throw new RuntimeException(e);
            
        }
        return null;        
    }
}
